package com.cloud.cloudvideo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloud.cloudvideo.entity.ResultModel;
import com.cloud.cloudvideo.entity.VideoMediaPo;
import com.cloud.cloudvideo.service.VideoRecycleService;

@Controller
@RequestMapping("/videoRecycle")
public class VideoRecycleController {

	@Autowired
	private VideoRecycleService videoRecycleService;
	
	@GetMapping("/tolist")
	public String list() {
		return  "manager/videorecycle/list";
	}
	
	
	@RequestMapping("/list")
	@ResponseBody
	public ResultModel<List<VideoMediaPo>> list(String mediaorginalname) {
		List<VideoMediaPo> list = videoRecycleService.list(mediaorginalname);
		return ResultModel.successWithData(list, list.size());
	}
	
	
	/**
	 * 恢复视频
	 * @param id
	 * @return
	 */
	@PostMapping("/recovery")
	@ResponseBody
	public ResultModel recovery(Long id) {
		videoRecycleService.recovery(id);
		return ResultModel.successWithNoData();
	}     
	
	
	/**
	 * 删除视频
	 * @param id
	 * @return
	 */
	@PostMapping("/del")
	@ResponseBody
	public ResultModel del(Long id) {
		videoRecycleService.del(id);
		return ResultModel.successWithNoData();
	}     
	
	
	
}
